home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Web Masters 11
/
WEB_11.iso
/
100domes
/
Antechinus JavaScript Editor 2.0
/
Setup.exe
/
Setups
/
JSEd
/
Installed
/
Solutions
/
Animation
/
cplib.js
< prev
next >
Wrap
Text File
|
2002-04-16
|
3KB
|
114 lines
// C Point JavaScript Library v3.6
// Copyright⌐ 1999-2002 C Point Pty Ltd, 71 Williamson Road, Para Hills 5096
// Web: http://www.c-point.com Email: c-point@c-point.com
// *************************************************************** //
// To use the C Point JavaScript Library you must be a registered
// user of Antechinus JavaScript Editor.
// *************************************************************** //
// ************ Move object functions ************
function initClassdraggable()
{
bMoving = false;
document.onmousedown=startMove;
document.onmousemove=moveObj;
document.onmouseup=new Function("bMoving=false");
}
function moveObj()
{
if(!bMoving) return true;
if(event.button!=1) return true;
// Reposition the object, keeping the same distance from the cursor
ob.style.pixelLeft=event.clientX-xdif;
ob.style.pixelTop=event.clientY-ydif;
return false;
}
function startMove()
{
// Only "draggable" objects can move
if(event.srcElement.className!="draggable") return;
bMoving=true;
// Store the object and the differnce between the obj pos and cursor pos: it must remain the same
ob=event.srcElement;
xdif=event.clientX-event.srcElement.style.pixelLeft;
ydif=event.clientY-event.srcElement.style.pixelTop;
}
// ************ Button Functions ************
// 2-state button (checkbox): function toggles the 2 states
function cpClickState(obj)
{
if(obj.cpType=="2")
{
obj.cpType="1";
obj.src=obj.cpDn;
}
else
{
obj.cpType="2";
obj.src=obj.cpUp;
}
}
function cpMouseOver(obj, f)
{
obj.src=f;
}
function cpMouseOut(obj, f)
{
obj.src=f;
}
// Move/display the object at the specified location
function cpPopup(ob2, x, y)
{
ob2.style.posLeft=x;
ob2.style.posTop=y;
ob2.style.visibility="visible";
}
// Roll the first object, display the second at the specified location
function cpMousePopOver(ob1, f, ob2, x, y)
{
cpMouseOver(ob1, f);
cpPopup(ob2, x, y);
}
// Roll the first object, display the second
function cpRollPopOver(ob1, f, ob2)
{
cpMouseOver(ob1, f);
ob2.style.visibility="visible";
}
// Restore the first object, hide the second
function cpMousePopOut(ob1, f, ob2)
{
cpMouseOut(ob1, f);
ob2.style.visibility="hidden";
}
// Toggle the object's visibility
function cpPop(ob)
{
if(ob.style.visibility=="visible") ob.style.visibility="hidden";
else ob.style.visibility="visible";
}
// ************ Misc functions ************
// Return the random number between min and max
function cpRandom(min, max)
{
var nRand = Math.random()*(max-min+1);
return(Math.round(nRand + 0.5)+min-1);
}